1. Technical Field
The present invention generally relates to object oriented computer graphics and imaging. More specifically, the present invention relates to methods and apparatus for facilitating the sharing of computer graphics operations in an object oriented computer system.
2. Background Information
The proliferation of computers, and particularly in conjunction with the explosion of computer software and the Internet, has led to a rise in the complexity and variety of computer software applications. A prominent feature of many software applications is the ability to display and manipulate computer graphic images. Given the variety and number of different software applications, computer graphic images can vary a great deal and are often stored in a wide variety of pixel formats. As a result, computer software applications need to support many different pixel formats and many different graphics or rendering operations.
Computer graphic images may be stored in many different pixels formats such as 32-bit integer RGB (Red-Green-Blue) values or 32-bit BGR integer (Blue-Green-Red) values. Presently known systems typically customize their computer graphics rendering operations (e.g., DrawLine, FillRect, etc.) for each specific pixel format. This is necessary as the same implementation of a particular rendering operation may not work on different pixel formats. For example, the implementation of FillRect (i.e., fill a rectangle with specific attributes such as color, shade pattern, etc.) for a 32-bit integer RGB pixel format would not work for a 1-bit black and white (B/W) pixel format.
However, an implementation of a particular rendering operation may be shared in certain instances. For example, the FillRect implementation for a 32-bit integer RGB pixel format may be shared by the FillRect implementation for a 32-bit integer BGR pixel format as both implementations use a 32-bit integer value to generate the fill value for the rectangle. However, presently known systems are limited in their ability to recognize when an implementation of a particular rendering operation may be shared, as there is no implicit detection of the similarity between pixel formats. The computer software has to have source code that identifies the two pixel formats and the particular rendering operation, whereupon xe2x80x9chard-codedxe2x80x9d logic directs the sharing of the rendering operation implementation between the two pixel formats.
Alternatively, the xe2x80x9chard-codedxe2x80x9d logic could be omitted, and instead the implementation of the common rendering operations for the different pixel formats could be duplicated for each pixel format. However, this necessarily leads to software that is complex and more apt to have xe2x80x9cbugsxe2x80x9d, and thus is more expensive to maintain and enhance, as bug fixes and enhancements have to be duplicated for the different implementations of the rendering operations. In addition, duplicating the rendering operations produces larger software executables which require more disk space and memory in order to function properly.
One popular approach to identifying pixel formats is that taken by platform independent application programming interfaces (APIs) such as OpenGL and QuickDraw 3D. These APIs provide a robust set of platform independent graphics primitives for various rendering operations from drawing lines, polylines, and polygons, to Gouraud and flat shading and the like. However, these APIs are limited in their ability to share implementations of common rendering operations among different pixel formats as the descriptors for the pixel formats are constants and do not support inheritance to derived or related pixel formats. Thus, these APIs must use hard-coded logic in order to share implementations of rendering operations for different pixel formats.
The present invention provides methods and apparatus for facilitating the sharing of implementations of rendering operations among different pixel formats. In accordance with one aspect of the present invention, a lookup table is generated having a plurality of software algorithm implementation descriptions. Each description may correspond to a rendering operation implementation or other type of software algorithm implementation. Each description comprises at least one attribute and may have a plurality of attributes such as a rendering operation type, a destination drawing surface data type, a source drawing surface data type, and a composition algorithm type. In addition, chains of a plurality of objects that are linked together are also generated. The objects can be implemented as C++ or Java objects having attributes and methods. The chains may comprise a chain of surface objects representing source or destination drawing surfaces. The chains may also comprise a chain of composition objects. Within each chain, the objects are linked together so that the supertype for a particular object can be easily accessed.
In accordance with another aspect of the present invention, the lookup table may be searched for a particular combination of attributes. The combination of attributes may comprise a specific rendering operation type and a specific destination drawing surface data type. If the specific combination of attributes is not found in the lookup table, then the chain of destination drawing surface objects may be traversed to find a supertype or more general description for the specified destination drawing surface data type. The lookup table may now be searched with the new combination of the specific rendering operation type and the supertype or more general destination drawing surface data type. This process can be repeated until a match is found or the chain of surface objects is fully traversed.
In accordance with another aspect of the present invention, the lookup table may be searched for a combination of attributes that includes a rendering operation type, a destination drawing surface data type, a source drawing surface data type, and a composition algorithm type. Linked chains of objects may be generated where the objects represent destination drawing surfaces, source drawing surfaces, and composition algorithms. If a match is not found in the lookup table for a specified combination of attributes, then the linked chains of objects may be traversed to obtain a supertype or more general description for one of the attributes. The lookup table can be searched again by substituting the supertype for one of the attributes. In this way, the lookup table can be iteratively searched until a match is found or the linked chains of objects are fully traversed.